package grpc.rpcclient;

import grpc.rpcclient.client.RpcClient;
import grpc.rpcprotocol.entity.DepartmentInfo;
import grpc.rpcprotocol.entity.UserInfo;
import grpc.rpcprotocol.service.DepartmentService;
import grpc.rpcprotocol.service.UserService;

import java.net.InetSocketAddress;

/**
 * @Author: admin
 * @Description:
 * @Date: 2018/9/28 15:44
 */

public class RpcClientTest {
    public static void main(String[] args){
        InetSocketAddress socketAddress=new InetSocketAddress("192.168.0.27",9999);
        RpcClient rpcClient=new RpcClient();
        UserService userService=rpcClient.getRemoteProxy(UserService.class,socketAddress);
        UserInfo userInfo=new UserInfo();
        userInfo.setId(111);
        userInfo.setName("rpc");
        Object res=userService.addUser(userInfo);
        System.out.println(res);
        DepartmentService departmentService=rpcClient.getRemoteProxy(DepartmentService.class,socketAddress);
        DepartmentInfo departmentInfo=new DepartmentInfo();
        departmentInfo.setId(123);
        departmentInfo.setName("网络部");
        res=departmentService.addDepartment(departmentInfo);
        System.out.println(res);
    }
}